package com.epi.one.basic.generic.pair;

import java.util.*;

/**
 * @author dxy
 * @version 1.0
 */
public class DatePair<T extends Date & Comparable<Date>> {
    private T a;
    private T b;

    public DatePair(T a, T b) {
        this.a = a;
        this.b = b;
    }

    public static void swap(DatePair p) {
        var temp = p.a;
        p.a = p.b;
        p.b = temp;
    }

    public static void swap2(DatePair<?> p) {
        swapHelp(p);
    }

    public static <T extends Date> void swapHelp(DatePair<T> p) {
        T temp = p.a;
        p.a = p.b;
        p.b = temp;
    }

    public static void print(DatePair p, Integer i) {
        printPair(p);
        switch (i) {
            case 1 -> swap(p);
            case 2 -> swap2(p);
            case 3 -> swapHelp(p);
        }
        printPair(p);
    }

    private static void printPair(DatePair<?> p) {
        System.out.println(p.a);
        System.out.println(p.b);
    }
}
